exports.install = function (Vue, options) {
    /**
     * 获取当前登陆用户的access_token
     * @Param key 调用组件见中当前data环境中需要承载参数的变量
     * @Author yangzeng 2019.7.17 */
    Vue.prototype.$accessToken = function(){
        return localStorage.getItem("user_token");
    };

    // 将数组对象转换为Tree结构数据对象
    Vue.prototype.$listToTree = function(data){
        let result = []
        if (!Array.isArray(data)) {
            return result
        }
        data.forEach(item => {
            delete item.children;
        });
        let map = {};
        data.forEach(item => {
            map[item.id] = item;
        });
        data.forEach(item => {
            let parent = map[item.pid];
            if (parent) {
                (parent.children || (parent.children = [])).push(item);
            } else {
                result.push(item);
            }
        });
        return result;
    }
};